﻿using System;
using OfficeOpenXml.Style;

namespace Colorful.Furniture.Epplus;

/// <summary>
///  导出属性标签
/// </summary>
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property)]
public class ExportAttribute : Attribute
{
    public ExportAttribute()
    {

    }

    /// <summary>
    ///  导出
    /// </summary>
    /// <param name="title">标题</param>
    public ExportAttribute(string title)
    {
        Title = title;
    }

    /// <summary>
    ///  导出
    /// </summary>
    /// <param name="title"></param>
    /// <param name="width"></param>
    public ExportAttribute(string title, int width)
    {
        Title = title;
        Width = width;
    }

    /// <summary>
    ///  标题
    /// </summary>
    public string Title { get; set; }

    /// <summary>
    ///  宽
    /// </summary>
    private int _width { get; set; }
    public int Width
    {
        get
        {
            if (_width == 0)
                return 4 * Title.Length;

            return _width;
        }

        set => _width = value;
    }

    /// <summary>
    ///  高度
    /// </summary>
    public int Height { get; set; } = 30;

    /// <summary>
    ///  是否隐藏
    /// </summary>
    public bool IsHide { get; set; }

    /// <summary>
    ///  横向
    /// </summary>
    public ExcelHorizontalAlignment HorizontalAlignment { get; set; } = ExcelHorizontalAlignment.Center;

    /// <summary>
    ///  纵向
    /// </summary>
    public ExcelVerticalAlignment VerticalAlignment { get; set; } = ExcelVerticalAlignment.Center;
}
